﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GroupCheer.FBGraphAPI.Core;

namespace GroupCheer.FBGraphAPI
{
    public class FBGraphAPIEventStateChangedEventArgs : EventArgs
    {
        public string EventData;
    }

    public class FBGraphAPIEventCompletedEventArgs : EventArgs
    {
        public bool isCompleted;
        public string EventData;
        public Exception LastException;
    }

    public class FBGraphAPIEventSink
    {
        public delegate void ExecuteStateChangedHandler(object sender, FBGraphAPIEventStateChangedEventArgs e);
        public delegate void ExecuteCompletedHandler(object sender, FBGraphAPIEventCompletedEventArgs e);

        public event ExecuteStateChangedHandler ExecuteStateChanged;
        public event ExecuteCompletedHandler ExecuteCompleted;

        public FBGraphAPIEventSink()
        {
            this.ExecuteStateChanged = Helpers.DefaultExecuteStateChangedHandler;
            this.ExecuteCompleted = Helpers.DefaultExecuteCompletedHandler;
        }

        public FBGraphAPIEventSink(ExecuteStateChangedHandler StateChangedHandler, ExecuteCompletedHandler CompletedHandler)
        {
            this.ExecuteCompleted = CompletedHandler;
            this.ExecuteStateChanged = StateChangedHandler;
        }

        public void OnExecuteStateChanged(object sender, FBGraphAPIEventStateChangedEventArgs e)
        {
            if (ExecuteStateChanged != null)
                ExecuteStateChanged(sender, e);
        }

        public void OnExecuteCompleted(object sender, FBGraphAPIEventCompletedEventArgs e)
        {
            if (ExecuteCompleted != null)
                ExecuteCompleted(sender, e);
        }
    }
}
